package com.shuhua.taskServer.service.impl;

<<<<<<< HEAD
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shuhua.pojo.entity.Admin;
import com.shuhua.pojo.entity.Craftsman;
import com.shuhua.taskServer.mapper.AdminMapper;
import com.shuhua.taskServer.mapper.CraftsmanMapper;
import com.shuhua.taskServer.service.security.GenericUserDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
=======
>>>>>>> 312a8547971bd28c72072d07caef702821bd7891
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
<<<<<<< HEAD
@Primary
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private AdminMapper adminMapper;
    @Autowired
    private CraftsmanMapper craftsmanMapper;

    @Override

    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        Admin admin = adminMapper.selectOne(new LambdaQueryWrapper<Admin>().eq(Admin::getUsername, username));
        if (admin != null) {
            return GenericUserDetails.createForAdmin(admin);
        }

        Craftsman craftsman = craftsmanMapper.selectOne(new LambdaQueryWrapper<Craftsman>().eq(Craftsman::getUsername, username));
        if (craftsman != null) {
            return GenericUserDetails.createForCraftsman(craftsman);
        }

        throw new UsernameNotFoundException("用户名不存在: " + username);
=======
public class UserDetailsServiceImpl implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        // 这里需要根据你的业务查询用户并返回UserDetails对象
        // 这里只是一个简单的示例，实际请根据你的用户表实现
        throw new UsernameNotFoundException("用户未找到: " + username);
>>>>>>> 312a8547971bd28c72072d07caef702821bd7891
    }
}